#include<bits/stdc++.h>
using namespace std;
const int NN=2e5+4;
char s[NN];
int l[NN],r[NN],x[NN];
int main()
{
	freopen("copy.in","r",stdin);
	freopen("copy.out","w",stdout);
	int k,n;
	scanf("%d%*d%s%d",&k,s,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&l[i],&r[i],&x[i]);
		r[i]--;
	}
	for(int i=0;i<k;i++)
	{
		int u=i;
		for(int j=n;j;j--)
			if(x[j]<=u&&x[j]+(r[j]-l[j])>=u)
				u=l[j]+u-x[j];
			else if(x[j]+(r[j]-l[j])<u)
				u-=r[j]-l[j]+1;
		printf("%c",s[u]);
	}
	return 0;
}
